using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {
	
	Vector3 headDown, headUp;
	public Transform head;
	
	void Start () {
		StartCoroutine(input());
		headUp = head.position;
		headDown = headUp;
		headDown.y -= 1.5f;
	}
	
	IEnumerator input()
	{
		while(true)
		{
			if(Input.GetKeyDown(KeyCode.Space))
			{
				float time = .3f, moveHeadTime = 0;
				while(moveHeadTime < time)
				{
					head.position = Vector3.Lerp(headUp, headDown, moveHeadTime/time);
					yield return 0;
					moveHeadTime += Time.deltaTime;
				}
				
				GameController.instance.Pain();
				
				moveHeadTime = 0;
				while(moveHeadTime < time)
				{
					head.position = Vector3.Lerp(headDown, headUp, moveHeadTime/time);
					yield return 0;
					moveHeadTime += Time.deltaTime;
				}
			}
			yield return 0;
		}
	}
}
